-- Decompiled with the Synapse X Luau decompiler.

local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerComponent());
function M.ctor(self, p2)
	M.super.ctor(self, p2);
end;
function M.dtor(self)
	M.super.dtor(self);
end;
function M.new(self)
	return M(self);
end;
function M.SetData(self, data)
	self.__save_data = data;
end;

function M.UpdateData(self, key,value)
	self.__save_data[key]=value;
end;


--模拟修改本地数据（假设服务器数据已改变）:keyList(表层级eg：{base,power}，修改力量),value新值
function M.SimulateModifyData(self, keyList,value)
	local data=self.__save_data
	for i=1,#keyList-1 do 
		data=data[keyList[i]]
	end
	data[keyList[#keyList]]=value
	local key=keyList[1]

	local sendData={
		[key]=self.__save_data[key]
	}

	self.parent.UserDataEvent:Action(sendData)
end;

function M.SimulateModifyDataAdd(self, keyList,value)
	local data=self.__save_data
	for i=1,#keyList-1 do 
		data=data[keyList[i]]
	end
	if not data[keyList[#keyList]] then
		data[keyList[#keyList]]=value
	else
		data[keyList[#keyList]]=value+data[keyList[#keyList]]
	end
	local key=keyList[1]

	local sendData={
		[key]=self.__save_data[key]
	}

	self.parent.UserDataEvent:Action(sendData)
end;

function M.GetData(self, key)
	assert(key, "param data name is nil");
	assert(self.__save_data[key]~=nil, "no save data named ..", key);
	
	return self.__save_data[key];
end;
return M;
